function WxConfig(){
	this.wxMenu = function(type){
		config(['hideOptionMenu', 'showOptionMenu']);
		
		wx.ready(function(){
			if(type == 'hide'){
				wx.hideOptionMenu();
			}else{
				wx.showOptionMenu();
			}
		});

		wx.error(function(e){
			console.error('wxMenu error : ' + JSON.stringify(e));
		});
	};

	function config(apiList){
		if(window.location.href.indexOf('localhost') > 0){
			return;
		}
		wx.config({
			debug : false,
			appId : getAppId(),
			timestamp : getItem('timestamp'),
			nonceStr : getItem('noncestr'),
			signature : signature(),
			jsApiList:apiList
		});
	};

	function getAppId(){
		var reg = new RegExp("(^|&)appid=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) {
            return decodeURI(r[2]);
        }
        return null;
	};

	function getItem(key){
		return window.localStorage.getItem(key);
	};

	function signature(){
		var ticket = getItem('jsapi_ticket'),
		    timestamp = getItem('timestamp'),
		    noncestr = getItem('noncestr');

		var str = 'jsapi_ticket=' + ticket + '&noncestr=' + noncestr + '&timestamp=' + timestamp + '&url=' + window.location.href;
		return hex_sha1(str);    
	};
};